package cn.qh.com.config;

import java.util.Date;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 添加更改自动改
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //新增时间
        //setFieldValByName("createdTime", new Date(), metaObject);
        //更新字段
        //setFieldValByName("updatedTime", new Date(), metaObject);
        //乐观锁新增是1 默认是1
        //setFieldValByName("version", 1, metaObject);
        //逻辑删除 默认是0
        //setFieldValByName("deleted", 0, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //更新字段
        //setFieldValByName("updatedTime", new Date(), metaObject);
    }
}

